import java.io.File;
import java.util.Random;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerConfigurationException;
import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;

import org.w3c.dom.Document;
import org.w3c.dom.Element;

public class Test {

	public static void main(String[] args) throws ParserConfigurationException, TransformerException {
		DocumentBuilderFactory dbfac = DocumentBuilderFactory.newInstance();
		DocumentBuilder docBuilder = dbfac.newDocumentBuilder();
		Document doc = docBuilder.newDocument();
		Element test = doc.createElement("test");
		test.setAttribute("name", "abc");
		test.setAttribute("datetime", "def");
        doc.appendChild(test);
        Element fitnessE = doc.createElement("fitness");
        fitnessE.setAttribute("name", "value");
        test.appendChild(fitnessE);
        
        Document doc1 = docBuilder.newDocument();
		doc1.adoptNode(test);
		doc1.appendChild(test);
        
        TransformerFactory transformerFactory = TransformerFactory.newInstance();
		Transformer transformer = transformerFactory.newTransformer();
		DOMSource source = new DOMSource(doc1);
		//StreamResult result = new StreamResult(new File("C:\\file.xml"));
		 
		// Output to console for testing
		// StreamResult result = new StreamResult(System.out);
 
		StreamResult result = new StreamResult(System.out);
		transformer.transform(source, result);
	}

	public static boolean complete(boolean[] dna) {
		for (int i = 0; i < dna.length; i++) {
			if (dna[i] == false)
				return false;
		}
		return true;
	}

}
